/**
 * Created with IntelliJ IDEA.
 * User: xi
 * Date: 13-11-26
 * Time: 下午6:10
 * To change this template use File | Settings | File Templates.
 */

var AnimateScroll = {
    i: 1,
    sTime: 0,
    tTime: 0,
    turns: 0,
    $target: null,
    h: 0,
    intervarlTime: 0,
    init: function (turns, tTime, sTime, target, h) {
        var _self = this;
        _self.turns = turns;
        _self.tTime = tTime;
        _self.sTime = sTime;
        _self.h = h;
        _self.$target = target;
    },
    /**
     * 滚动动画 启动
     * @param turns 轮询次数，行数
     * @param tTime 间隔时间
     * @param sTime 动画时间
     * @param target 目标对像jquer
     * @param h 单行高度
     */
    start: function (turns, tTime, sTime, target, h) {
        var _self = this;
        _self.init(turns, tTime, sTime, target, h);
        _self.i = 1;
        _self.intervarlTime = setInterval(function () {
            if (_self.i == _self.turns) {
                _self.i = 0;
                _self.$target.css("top", _self.h);
            }
            _self.$target.css("position", "relative");
            var top = _self.$target.css("top");
            if (!top || top == "auto") {
                top = 0;
            } else {
                top = parseInt(top.replace("px", ""));
            }
            top = top - _self.h;
            _self.$target.animate({
                top: top
            }, _self.sTime, function () {
                _self.i++;
            });
        }, _self.tTime);
    },
    stop: function () {
        var _self = this;
        clearInterval(_self.intervarlTime);
    }

}
//AnimateScroll.start(3, 3 * 1000, 1 * 1000, $(".adv_box ul"), 61);

$(function () {
    setInterval(function () {
        $(".adv_box ul li").hide();
        $(".adv_box ul li").last().fadeOut(3500, function () {
            var last = $(".circle_icon_bar i").last();
            $(".circle_icon_bar").prepend(last);
            var pic = $(".adv_box ul li").first();
            $(".adv_box ul").append(pic);
            pic.fadeIn(1500);

        });

    }, 30 * 1000);


});